﻿using Backend.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Backend.Data.Managers
{
    public class StateManager
    {
        public static List<State> GetAll()
        {
            using (BackendDbContext db = new BackendDbContext())
            {
                //return from s in c.States select s; //
                return db.States.ToList();
            }
        }
        public static List<State> GetListByFilter(string filter)
        {
            using (BackendDbContext db = new BackendDbContext())
            {
                
                return db.States.Where(t=> t.Price.ToString().Contains(filter)).ToList();
            }
        }

        public static State Create(State state)
        {
            using (BackendDbContext db = new BackendDbContext())
            {

                State stateDB = db.States.Add(state);
                db.SaveChanges();


                return stateDB;
            }
        }
    }
}
